package com.qf.controller;

import com.qf.pojo.Userdetails;
import com.qf.service.UserdetailsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class UserdetailsController {
    @Resource
    UserdetailsService userdetailsService;
    @RequestMapping("/findAllUserdetails")
    public List<Userdetails> findAllUserdetails(){

        return userdetailsService.findAll();
    }

    @RequestMapping(value = "/addUserdetails",method = RequestMethod.POST)
    public int addUserdetails(@RequestBody Userdetails userdetails){
        int add = userdetailsService.add(userdetails);
        if (add>0){
            return 1;
        }else {
            return 0;
        }
    }
    @RequestMapping(value = "/updateUserdetails",method = RequestMethod.POST)
    public int updateUserdetails(@RequestBody Userdetails userdetails){
        int update = userdetailsService.update(userdetails);
        if (update>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/deleteUserdetails/{udid}")
    public int deleteUserdetails(@PathVariable("udid")int udid) {
        int delete = userdetailsService.delete(udid);
        if (delete>0){
            return 1;
        }else {
            return 0;
        }
    }

    @RequestMapping("/findUserdetailsByUdid/{udid}")
    public Userdetails findUserdetailsByUdid(@PathVariable("udid")int udid){

        return userdetailsService.findUserdetailsByUdid(udid);
    }
}
